from django.db import models
from common.models import AccessionModel
from django.contrib.auth.models import User

# Create your models here.
class Lab(AccessionModel):
    """
    TODO:
    - add restriction to only allow one lab at a time!
    """
    
    PATH_DEFAULT = "{{ obj.name }}"
    PATH_TYPE_DEFAULT = AccessionModel.DIR
    
    name = models.CharField(max_length=100, unique=True)
    
    class Meta:
        app_label = 'lab'
    

class Researcher(models.Model):
    user = models.ForeignKey(User, unique=True)
    lab = models.ForeignKey(Lab)
    
    def __unicode__(self):
        name = self.user.first_name + " " + self.user.last_name
        name = name.strip()
        if name == "":
            return "No Name"
        else:
            return name
    
    class Meta:
        unique_together = (('user', 'lab'),)
    

